package com.mjkj.demo.core.page;

/**
 * 分页数据类
 *
 * @author cwh
 * @date 2023-01-07
 */


import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.List;

@ApiModel("分页数据")
public class ListData<T> {
    @ApiModelProperty("数据总数")
    long count;
    @ApiModelProperty("查询结果列表")
    List<T> list;

    private ListData(IPage pageData) {
        this.count = pageData.getTotal();
        this.list = pageData.getRecords();
    }

    private ListData(long count,List<T> list) {
        this.count = count;
        this.list = list;
    }



    @Override
    public String toString() {
        return "ListData{" +
                "count=" + count +
                ", list=" + list +
                '}';
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public static<T> ListData build(IPage<T> pageData){
        return new ListData(pageData);
    }

    public static<T> ListData build(long count,List<T> list){
        return new ListData(count,list);
    }
}
